package top.starmc.starpet.util

import taboolib.common.util.replaceWithOrder
import top.starmc.starpet.config.Config

fun MutableList<String>.calculate(prefix: String, suffix: String, vararg args: Any): MutableList<String> {
    replaceAll {
        var line = it.replaceWithOrder(*args)
        if (prefix in line && suffix in line) {
            for (text in line.extract(prefix, suffix)) {
                line = line.replace("$prefix$text$suffix", Config.numberFormat.format(text.calculate()))
            }
        }
        line
    }
    return this
}